#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QMenu>
#include <QCursor>
#include <QAction>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QDebug>
#include <QSslConfiguration>
#include <QSslSocket>
#include <QHostAddress>
#include <QMessageBox>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonDocument>
#include <QDateTime>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QSqlRecord>
#include <QPainter>
#include "weathe_data.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private slots:
    void on_pushButton_clicked();

private:
    Ui::Widget *ui;

protected:
    void contextMenuEvent(QContextMenuEvent *event);

    //获取天气信息
    void getWeatherInfo(QString cityCode);

    void parseJson(QByteArray &byteArray);

    void updataUI();

    //重写父类的方法
    bool eventFilter(QObject * watched,QEvent *event);

    //绘制高低温曲线
    void paintHighCurve();
    void paintLowcurve();

private slots:

    void  onReplied(QNetworkReply *reply);

    void on_pushButton_2_clicked();


private:
    QMenu *mExitMenu;//右键退出的菜单
    QAction *mExitAct;//退出的菜单项

    QNetworkAccessManager * mNetworkAccessManager;

    Today mToday;
    Day mDay[6];
    //星期和日期
    QList<QLabel*> mweekList;
    QList<QLabel*> mdateList;

    //天气和天气图标
    QList<QLabel*> mtypeList;
    QList<QLabel*> mtypeIconList;

    //污染图标
    QList<QLabel*> mAqiList;

    //风力和风向图标
    QList<QLabel*> mflList;
    QList<QLabel*> mfxList;

    QMap<QString,QString> mTypeMap;

    QSqlDatabase db;
    QSqlQuery query;

    QString key_data;
};
#endif // WIDGET_H
